<template>
  <div id="playAll">
    <van-button icon="play" @click="playAll" plain round size="mini"
      >播放全部</van-button>
  </div>
</template>

<script>
export default {
  name: 'PlayAll',
  props: {
    songData: {
      type: [Object, Array],
      required: true
    }
  },
  data () {
    return {
    }
  },

  // 定义方法
  methods: {
    playAll () {
      this.$store.commit('music/loadPlayMusicList', this.songData)
      this.$nextTick(() => {
        this.$store.commit('music/loadPlayMusicIndex', 0)
      })
      this.$store.commit('play/loadPaused', false)
      this.$store.dispatch('play/getMusicSrc', this.songData[0].mid)
    }
  }
}
</script>

<style scoped lang="less">
.van-button {
  text-align: right;
  border: 1px solid #ccc;
  padding: 0 10px;
}
</style>
